class Solution
{
public:
    int sumOfTheDigitsOfHarshadNumber(int x)
    {
        int digitSum = 0;
        int xx = x;
        while (x)
        {
            digitSum += x % 10;
            x /= 10;
        }
        return xx % digitSum == 0 ? digitSum : -1;
    }
};